package com.fengke.cn.yejian11.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.fengke.cn.yejian11.R;
import com.fengke.cn.yejian11.config.Config;
import com.fengke.cn.yejian11.impls.ActImpls;
import com.fengke.cn.yejian11.javabean.YueJian;
import com.squareup.picasso.Picasso;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class AboutYueJianActivity extends Activity {

    private TextView yuejian_name;
    private TextView yuejian_content;
    private ImageView yuejian_pic;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_yue_jian);

        yuejian_name= (TextView) findViewById(R.id.about_yuejiann);
        yuejian_content= (TextView) findViewById(R.id.about_yuejianc);
        yuejian_pic= (ImageView) findViewById(R.id.about_yuejianp);
        Retrofit retrofit=new Retrofit.Builder().addConverterFactory(GsonConverterFactory.create()).baseUrl(Config.URL).build();
        ActImpls services=retrofit.create(ActImpls.class);
        Call<YueJian> call=services.getYueJian();
        call.enqueue(new Callback<YueJian>() {
            @Override
            public void onResponse(Call<YueJian> call, Response<YueJian> response) {
                YueJian yueJian=response.body();
                yuejian_name.setText(yueJian.getCorpname());
                Picasso.with(AboutYueJianActivity.this).load(R.drawable.bg_login).into(yuejian_pic);
                yuejian_content.setText(yueJian.getContact());
            }

            @Override
            public void onFailure(Call<YueJian> call, Throwable t) {

                Toast.makeText(AboutYueJianActivity.this,"获取消息失败",Toast.LENGTH_LONG).show();
            }
        });

    }
}
